# 需求：把小于房子剩余空间的家具摆放到房子中去

# 房子类
class Home():
    def __init__(self, address, area):
        # 地理位置
        self.address = address
        # 房屋面积
        self.area = area
        # 剩余面积
        self.free_area = area
        # 家具列表
        self.furnitures = []

    def add_furnitures(self, *args):
        # 逐一添加家具
        for furniture in args:
            if self.free_area >= furniture.area:
                self.furnitures.append(furniture.name)
                # 更新房屋剩余面积
                self.free_area -= furniture.area
            else:
                print('房屋的剩余面积不足，无法再添置家具。')

    def __str__(self):
        return f'房子的地理位置在{self.address}.房屋面积是{self.area},' \
               f'其中的家具有{self.furnitures},剩余面积有{self.free_area}'


# 家具类
class Furniture():
    def __init__(self, name, area):
        # 家具名字
        self.name = name
        # 家具占地面积
        self.area = area
    

# 家具对象
bed = Furniture('双人床', 10)
sofa = Furniture('沙发', 5)

# 房子对象
home1 = Home('北京', 15)
home1.add_furnitures(bed, sofa)
print(home1)
